package com.huobi;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeansException;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.huobi.pro.market.client.LinearswapClient;

@SpringBootApplication
@EnableScheduling
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class MarkerRunner implements ApplicationRunner, ApplicationContextAware  {

	private ApplicationContext applicationContext;
	
	
    public static void main(String[] args) throws Exception {
        SpringApplication app = new SpringApplication(MarkerRunner.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run(args);
    }

    public void run(ApplicationArguments args) throws Exception {
        LinearswapClient wssMarketHandle =(LinearswapClient) applicationContext.getBean("LinearswapClient");
        List<String> channels = new ArrayList<>();
        channels.add("market.TRX-USDT.trade.detail");
        channels.add("market.TRX-USDT.kline.1min");
        // channels.add("market.BTC-USDT.kline.15min");
        // channels.add("market.BTC-USDT.kline.30min");
        // channels.add("market.BTC-USDT.kline.60min");
        // channels.add("market.BTC-USDT.kline.4hour");
        // channels.add("market.BTC-USDT.kline.1day");
        // channels.add("market.BTC-USDT.kline.1week");
        // channels.add("market.BTC-USDT.kline.1mon");
        wssMarketHandle.sub(channels);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

}